<?php
/**
 * Created by PhpStorm.
 * User: root
 * Date: 18-11-1
 * Time: 下午1:49
 */

namespace App\Model;


use App\Utility\Pool\MysqlObject;
use EasySwoole\ORM\Db\MysqlPool;
use EasySwoole\Pool\Manager as PoolManager;

class BaseModel
{
    private $db;
    function __construct(MysqlObject $db)
    {
        $this->db = $db;
    }

    function getDbConnection():MysqlObject
    {
        return $this->db;
    }

    function __destruct()
    {
        // TODO: Implement __destruct() method.
        if ($this->db instanceof MysqlObject) {
            PoolManager::getInstance()->getPool(MysqlPool::class)->recycleObj($this->db);
        }
    }
}